package com.example.cloud_300.controller;

import com.example.cloud_300.service.ImportService;
import com.example.cloud_300.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Validated
@Slf4j
public class ImportController {

    private static final Logger logger = LoggerFactory.getLogger(ImportController.class);

    @Autowired
    private ImportService importService;

    @PostMapping(value = "/importExcel")
    public Result importExcel() {
        try {
            importService.importExcel();
            return Result.success();
        } catch (Exception e) {
            log.error("import excel error", e);
            return Result.error(e.getMessage());
        }
    }
}